<template>
	<view class="container">
		<view class="use-box">
			<view class="use-item" v-for="(item,index) in dataList" :key="index">
				<view class="time v-center">佣金提现 
				<view class="statu center" v-if="item.status == 0">审核中</view>
				 <view class="statu center end" v-if="item.status == 1">已完成</view>
				 <view class="statu center" v-if="item.status == 2">已拒绝</view>
				</view>
				<view class="space-between cont">
					<view class="left">
						<view class="text space-between">申请时间：{{item.createTime}}</view>
						<view class="text">提现银行：{{item.bankName}}（{{item.bankNo}}）</view>
						<view class="text">订单号：{{item.id}}</view>
					</view>
					<view class="right">
						<view class="money">￥{{item.price}}</view>
						<image  @click="copyText(item.id)" src="https://fuqiaohui.oss-cn-chengdu.aliyuncs.com/merchant/copy.png" class="copy-img"></image>
					</view>
				</view>
			</view>
		</view>
		<view class="no-data" v-if="!dataList.length">暂无数据</view>
		<view class="no-data" v-if="noMore">没有更多了</view>
	</view>
</template>

<script>
	import {
		getList
	} from '../../api/active'
	import {
		getTimeBytimeStamp
	} from '../../utils/plug.js'
	export default {
		data() {
			return {
				size: 10,
				show: false,
				current: 1,
				noMore: false,
				dataList: []
			}
		},
		onLoad() {
			this.getData()
		},
		methods: {
			getData() {
				uni.showLoading({
					title: "加载中..."
				})
				getList({
						staffId: uni.getStorageSync("userId"),
						size: this.size,
						current: this.current
					})
					.then(res => {
						this.show = true;
						uni.hideLoading()
						uni.stopPullDownRefresh()
						if(this.current == 1) {
							this.dataList = res.data.records
						}else {
							this.dataList = [...this.dataList,...res.data.records]
						}
						if (res.data.records.length) {
							this.dataList.forEach(item => {
								item.createTime = getTimeBytimeStamp(item.createTime)
								let number = item.bankNo;
								let str = number.toString(); // 将数字转换为字符串
								let lastFour = str.slice(-4);
								item.bankNo = lastFour
							})
							if (res.data.total > this.current * this.size) {
								this.noMore = false
								this.current++
							} else {
								this.noMore = true;
							}
						}
					})
					.catch(() => {
						uni.hideLoading()
						uni.stopPullDownRefresh()
					})
			},
			copyText(text) {
				uni.setClipboardData({
					data: text.toString(),
					success() {
						uni.showToast({
							title: "复制成功",
							icon: "none",
							duration: 2000
						})
					},
					fail() {
						console.log('复制失败')
					}
				})
			}
		},
		onPullDownRefresh() {
			this.current = 1
			this.noMore = false;
			this.getData()
		},
		onReachBottom() {
			if (!this.noMore) {
				this.getData()
			}
		}
	}
</script>

<style lang="scss" scoped>
	.no-data {
		font-weight: 500;
		font-size: 26rpx;
		color: #999999;
		text-align: center;
		padding-top: 20rpx;
	}

	.statu {
		width: 100rpx;
		height: 47rpx;
		background: #f7eec3;
		border-radius: 5rpx;
		margin-left: 14rpx;
		font-weight: 800;
		font-size: 24rpx;
		color: #da950f;

		&.end {
			background: #ebf9ee;
			color: #03b521;
		}
	}

	.money {
		font-weight: 800;
		font-size: 34rpx;
		color: #333333;
		margin-bottom: 74rpx;
	}

	.container {
		width: 100vw;
		background: #f5f5f5;
		padding-bottom: 20rpx;
	}

	.use-box {
		display: flex;
		flex-direction: column;
	}

	.use-item {
		width: 100%;
		height: 288rpx;
		background: #ffffff;
		padding: 0 24rpx;
		margin-top: 20rpx;
		.time {
			height: 80rpx;
			font-weight: 800;
			font-size: 30rpx;
			color: #333333;
			border-bottom: 1px solid #f1f1f1;
		}
	}

	.cont {
		margin-top: 30rpx;
		align-items: flex-end;

		.left {
			display: flex;
			flex-direction: column;
			gap: 20rpx;

			.text {
				font-weight: 500;
				font-size: 28rpx;
				color: #666666;
			}
		}

		.right {
			display: flex;
			justify-content: flex-end;
			flex-direction: column;
			align-items: flex-end;

			.copy-img {
				width: 31rpx;
				height: 31rpx;
			}
		}
	}
</style>